<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2.折叠面板</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .container {
      margin: 100px auto;
      width: 500px;
      padding: 40px;
      border: 5px solid purple;
      border-radius: 20px;
      box-shadow: 4px 4px 13px rgba(0, 0, 0, .3);
    }

    .container>h2 {
      margin-bottom: 20px;
      text-align: center;
    }

    .box {
      border: 1px solid #ccc;
    }

    .box .hd {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 15px;
      height: 40px;
      font-size: 18px;
      border-bottom: 1px solid #ccc;
    }

    .box .txt {
      font-weight: 700;
    }

    .box .hd .close {
      cursor: pointer;
    }

    .box .bd {
      padding: 0 15px;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="container">
      <h2>案例：折叠面板</h2>
      <div class="box">
        <div class="hd">
          <div class="txt">芙蓉楼送辛渐</div>
          <div class="close" @click="toggle">{{isshow?'收起':'展开'}}</div>
        </div>
        <div v-show="isshow" class="bd">
          <p>寒雨连江夜入吴，</p>
          <p>平明送客楚山孤。</p>
          <p>洛阳亲友如相问，</p>
          <p>一片冰心在玉壶。</p>
        </div>
      </div>
    </div>
  </div>
  <script src="vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        isshow: true
      },
      methods: {
        toggle() {
          this.isshow = !this.isshow
        }
      }
    })
  </script>
</body>

</html>